home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / version.pod < prev    next >
Encoding:
Text File  |  2007-03-05  |  6.3 KB  |  236 lines

  1. =head1 NAME
  2.  
  3. Glib::version -  Library Versioning Utilities
  4.  
  5. =for position SYNOPSIS
  6.  
  7. =head1 SYNOPSIS
  8.  
  9.   # require at least version 1.021 of the Glib module
  10.   use Glib '1.021';
  11.  
  12.   # g_set_application_name() was introduced in GLib 2.2.0, and
  13.   # first supported by version 1.040 of the Glib Perl module.
  14.   if ($Glib::VERSION >= 1.040 and Glib->CHECK_VERSION (2,2,0)) {
  15.      Glib::set_application_name ('My Cool Program');
  16.   }
  17.  
  18. =for position DESCRIPTION
  19.  
  20. =head1 DESCRIPTION
  21.  
  22. Both the Glib module and the GLib C library are works-in-progress, and 
  23. their interfaces grow over time.  As more features are added to each, 
  24. and your code uses those new features, you will introduce 
  25. version-specific dependencies, and naturally, you'll want to be able to 
  26. code around them.  Enter the versioning API.
  27.  
  28. For simple Perl modules, a single version number is sufficient; 
  29. however, Glib is a binding to another software library, and this 
  30. introduces some complexity.  We have three versions that fully specify 
  31. the API available to you.
  32.  
  33. =over
  34.  
  35. =item Perl Bindings Version
  36.  
  37. Perl modules use a version number, and Glib is no exception.  
  38. I<$Glib::VERSION> is the version of the current Glib module.  By ad hoc 
  39. convention, gtk2-perl modules generally use version numbers in the form 
  40. x.yyz, where even yy values denote stable releases and z is a 
  41. patchlevel.
  42.  
  43.    $Glib::VERSION
  44.    use Glib 1.040; # require at least version 1.040
  45.  
  46. =item Compile-time ("Bound") Library Version
  47.  
  48. This is the version of the GLib C library that was available when the 
  49. Perl module was compiled and installed.  These version constants are 
  50. equivalent to the version macros provided in the GLib C headers.  GLib 
  51. uses a major.minor.micro convention, where even minor versions are 
  52. stable.  (gtk2-perl does not officially support unstable versions.)
  53.  
  54.    Glib::MAJOR_VERSION
  55.    Glib::MINOR_VERSION
  56.    Glib::MICRO_VERSION
  57.    Glib->CHECK_VERSION($maj,$min,$mic)
  58.  
  59. =item Run-time ("Linked") Library Version
  60.  
  61. This is the version of the GLib C library that is available at run 
  62. time; it may be newer than the compile-time version, but should never 
  63. be older.  These are equivalent to the version variables exported by 
  64. the GLib C library.
  65.  
  66.    Glib::major_version
  67.    Glib::minor_version
  68.    Glib::micro_version
  69.  
  70. =back
  71.  
  72. =head2 Which one do I use when?
  73.  
  74. Where do you use which version?  It depends entirely on what you're 
  75. doing.  Let's explain by example:
  76.  
  77. =over
  78.  
  79. =item o Use the Perl module version for bindings support issues
  80.  
  81. You need to register a new enum for use as the type of an object 
  82. property.  This is something you can do with all versions of the 
  83. underlying C library, but which wasn't supported in the Glib Perl 
  84. module until $Glib::VERSION >= 1.040.
  85.  
  86. =item o Use the bound version for library features
  87.  
  88. You want to call Glib::set_application_name to set a human-readable name
  89. for your application (which is used by various parts of Gtk2 and Gnome2).
  90. g_set_application_name() (the underlying C function) was added in version
  91. 2.2.0 of glib, and support for it was introduced into the Glib Perl module
  92. in Glib version 1.040.  However, you can build the Perl module against any
  93. stable 2.x.x version of glib, so you might not have that function available
  94. even if your Glib module is new enough!
  95.   Thus, you need to check two things to see if the this function is 
  96. available:
  97.  
  98.    if ($Glib::VERSION >= 1.040 && Glib->CHECK_VERSION (2,2,0)) {
  99.        # it's available, and we can call it!
  100.        Glib::set_application_name ('My Cool Application');
  101.    }
  102.  
  103. Now what happens if you installed the Perl module when your system had 
  104. glib 2.0.6, and you upgraded glib to 2.4.1?  Wouldn't g_set_application_name() 
  105. be available?  Well, it's there, under the hood, but the bindings were 
  106. compiled when it wasn't there, so you won't be able to call it! 
  107. That's why we check the "bound" or compile-time version.  By the way, to 
  108. enable support for the new function, you'd need to reinstall (or upgrade)
  109. the Perl module.
  110.  
  111. =item o Use the linked version for runtime work-arounds
  112.  
  113. Suppose there's a function whose API did not change, but whose 
  114. implementation had a bug in one version that was fixed in another 
  115. version.  To determine whether you need to apply a workaround, you 
  116. would check the version that is actually being used at runtime.
  117.  
  118.    if (Glib::major_version == 2 &&
  119.        Glib::minor_version == 2 &&
  120.        Glib::micro_version == 1) {
  121.       # work around bug that exists only in glib 2.2.1.
  122.    }
  123.  
  124. In practice, such situations are very rare.
  125.  
  126. =back
  127.  
  128. =cut
  129.  
  130.  
  131.  
  132. =for object Glib::version Library Versioning Utilities
  133. =cut
  134.  
  135.  
  136.  
  137.  
  138. =head1 METHODS
  139.  
  140. =head2 boolean = Glib-E<gt>B<CHECK_VERSION> ($required_major, $required_minor, $required_micro)
  141.  
  142. =over
  143.  
  144. =over
  145.  
  146. =item * $required_major (integer) 
  147.  
  148. =item * $required_minor (integer) 
  149.  
  150. =item * $required_micro (integer) 
  151.  
  152. =back
  153.  
  154. Provides a mechanism for checking the version information that Glib was
  155. compiled against. Essentially equvilent to the macro GLIB_CHECK_VERSION.
  156.  
  157. =back
  158.  
  159. =head2 (MAJOR, MINOR, MICRO) = Glib->B<GET_VERSION_INFO>
  160.  
  161. =over
  162.  
  163. Shorthand to fetch as a list the glib version for which Glib was compiled.
  164. See C<Glib::MAJOR_VERSION>, etc.
  165.  
  166. =back
  167.  
  168. =head2 integer = Glib::MAJOR_VERSION 
  169.  
  170. =over
  171.  
  172. Provides access to the version information that Glib was compiled against.
  173. Essentially equivalent to the #define's GLIB_MAJOR_VERSION.
  174.  
  175. =back
  176.  
  177. =head2 integer = Glib::MICRO_VERSION 
  178.  
  179. =over
  180.  
  181. Provides access to the version information that Glib was compiled against.
  182. Essentially equivalent to the #define's GLIB_MICRO_VERSION.
  183.  
  184. =back
  185.  
  186. =head2 integer = Glib::MINOR_VERSION 
  187.  
  188. =over
  189.  
  190. Provides access to the version information that Glib was compiled against.
  191. Essentially equivalent to the #define's GLIB_MINOR_VERSION.
  192.  
  193. =back
  194.  
  195. =head2 integer = Glib::major_version 
  196.  
  197. =over
  198.  
  199. Provides access to the version information that Glib is linked against.
  200. Essentially equivalent to the global variable glib_major_version.
  201.  
  202. =back
  203.  
  204. =head2 integer = Glib::micro_version 
  205.  
  206. =over
  207.  
  208. Provides access to the version information that Glib is linked against.
  209. Essentially equivalent to the global variable glib_micro_version.
  210.  
  211. =back
  212.  
  213. =head2 integer = Glib::minor_version 
  214.  
  215. =over
  216.  
  217. Provides access to the version information that Glib is linked against.
  218. Essentially equivalent to the global variable glib_minor_version.
  219.  
  220. =back
  221.  
  222.  
  223. =head1 SEE ALSO
  224.  
  225. L<Glib>
  226.  
  227. =head1 COPYRIGHT
  228.  
  229. Copyright (C) 2003-2006 by the gtk2-perl team.
  230.  
  231. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  232.  
  233.  
  234. =cut
  235.  
  236.